#ifndef MESSAGING_H
#define MESSAGING_H

#include <QObject>
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "QTime"

enum stateReceive {
    DEFAULT = -1,
    START1 = 0,
    START2,
    START3,
    START4,
    START5,
    END1,
    END2,
    END3,
    END4,
    END5,
};

class Messaging : public QObject
{
    Q_OBJECT
public:
    explicit Messaging(Ui::MainWindow* ui, QObject *parent = 0);

signals:
    void plot(QList<float> values);
    void drawImage(QByteArray data);

public slots:
    void receiveMsg(QByteArray *msg);

private:
    Ui::MainWindow *ui;

    QTime frameTimeout;
    bool waitingForFrameToComplete;
    float Char2Float(char* buf);
    bool parseMsg(QByteArray *msg, QByteArray *payload, char* frameType, uint16_t* frameLength);

};

#endif // MESSAGING_H
